shout3d.core
Class Field

java.lang.Object
  |
  +--shout3d.core.Field
Direct Known Subclasses:
ArrayField, BooleanField, DoubleField, FloatField, IntField, NodeField, StringField

public abstract class Field
extends java.lang.Object
implements UsageTypes

An abstract class which is subclassed to create Shout3D Fields


Constructor Summary
Field(Node owner, java.lang.String name, int usage)
          Constructs this Field
 
Method Summary
 void addFieldObserver(FieldObserver fo, java.lang.Object userData)
          This method registers the interest of a FieldObserver
 boolean addRoute(Field toField)
          Adds a route that copies values from this field to 'toField' each time that fromField's value changes.
 boolean deleteRoute(Field toField)
          Removes any existing route from this field to toField Returns true if a route existed and was removed, false otherwise Note: Routes of ArrayFields copy by reference, not by value.
 void fieldNotify()
          Notifies all registered observers and routes that the field was changed.
 java.lang.String getName()
          Gets this Field's name.
 int getNumRoutes()
          Returns the number of fields to which this field is routed.
 Node getOwner()
          Gets this Field's owner.
 Field getRoutedField(int i)
          Returns a field to which this field is routed to.
 java.lang.String getTypeName()
          Gets a string representing this Field's type
 int getUsage()
          Gets this Field's usageType.
 java.lang.String getValueByString()
           
 boolean isOfType(java.lang.String type)
          Returns whether this field is of the same type, or a type derived from, the Field type given by the input string.
 boolean isRouted(Field toField)
          Checks if a route currently exists from this field to toField
 void removeFieldObserver(FieldObserver fo)
          This method unregisters the interest of a FieldObserver
 void setValueByString(java.lang.String string)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Field

public Field(Node owner,
             java.lang.String name,
             int usage)
Constructs this Field
Parameters:
owner - this field's owner
name - this field's name
usage - this field's usage
Method Detail

getOwner

public Node getOwner()
Gets this Field's owner.

getUsage

public int getUsage()
Gets this Field's usageType.

getName

public java.lang.String getName()
Gets this Field's name.

getTypeName

public java.lang.String getTypeName()
Gets a string representing this Field's type
Returns:
the string

isOfType

public boolean isOfType(java.lang.String type)
Returns whether this field is of the same type, or a type derived from, the Field type given by the input string.
Parameters:
type - the field type string

addFieldObserver

public void addFieldObserver(FieldObserver fo,
                             java.lang.Object userData)
This method registers the interest of a FieldObserver
Parameters:
observer - the FieldObserver
userData - data that will be passed back to the observer's onFieldChange method.

removeFieldObserver

public void removeFieldObserver(FieldObserver fo)
This method unregisters the interest of a FieldObserver
Parameters:
observer - the FieldObserver to unregister

addRoute

public boolean addRoute(Field toField)
                 throws Shout3DException
Adds a route that copies values from this field to 'toField' each time that fromField's value changes. 'toField' will, in turn, notify any listeners or routed fields of this change. Does not copy the value immediately from this field to toField. So the values will not be made to match until setValue() is called on this field. (Note: this behavior was different in prior to Shout3D 1.0.3. In Shout3D 1.0, 1.0.1, and 1.0.2, addRoute() would copy the value from this field to toField, so the values would match after this call.) Note: Routes of ArrayFields copy by reference, not by value. This makes routing of ArrayFields efficient, since a value change does not cause a copy the array contents. However, deleting the route does not undo the fact that both fields refer to the array in memory. (See deleteRoute for more info). Throws a Shout3DException if toField is not of a type derived from this one. Will not add a second route if a route already exists. Returns true if a route was added, false otherwise
Parameters:
toField - the field to which values will be copied
Returns:
true if the route was added, false otherwise

deleteRoute

public boolean deleteRoute(Field toField)
Removes any existing route from this field to toField Returns true if a route existed and was removed, false otherwise Note: Routes of ArrayFields copy by reference, not by value. (see addRoute) Deleting a route does not undo the fact that both fields refer to the array in memory. If you want to insure that the toField refers to unique memory, you should allocate a new value array of the same size as the source field, copy the values into the new array, and set this new array as the toField's value.
Parameters:
toField - the field to which values will be copied
Returns:
true if the route was removed, false otherwise

getNumRoutes

public int getNumRoutes()
Returns the number of fields to which this field is routed.
Returns:
the number of fields to which this field is routed

getRoutedField

public Field getRoutedField(int i)
Returns a field to which this field is routed to. You can find all the the routed fields by looping from 0 to getNumRoutes()-1
Returns:
the number of fields to which this field is routed

isRouted

public boolean isRouted(Field toField)
Checks if a route currently exists from this field to toField
Returns:
true if the route exists, false otherwise

fieldNotify

public void fieldNotify()
Notifies all registered observers and routes that the field was changed. This method insures that the field value is sent along all connected routes from this field and calls the onFieldChange() method of all FieldObservers that are observing this field. fieldNotify() is called automatically whenever setValue() (or set1Value() in the case of ArrayFields) is called. However, users who hold a reference to the array value of an array field may choose to edit numerous elements of the array and then simply call fieldNotify() on the field when they are finished, in order to propogate knowledge of the changes througout the applet.

setValueByString

public void setValueByString(java.lang.String string)

getValueByString

public java.lang.String getValueByString()